/*
 *   This File is Part of CuteOgre Game Engine
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *	Copyright 2010 Alexandre Pires ( c.alexandre.pires@gmail.com )
 *  Created on: 2010/09/05
 */

#ifndef STYLEATTRIBUTE_H_
#define STYLEATTRIBUTE_H_

#include <QString>
#include <QStringList>
#include <QColor>

class StyleAttribute {

	friend class Style;

public:
	enum AttributeUnits {
		UNIT_IN = 0 , UNIT_CM, UNIT_MM, UNIT_PT, UNIT_PC, UNIT_PX, UNIT_REM,
		UNIT_PERCENT, UNIT_EX, UNIT_GD, UNIT_EM, UNIT_VW, UNIT_VH, UNIT_VM,
		UNIT_CH, UNIT_DEG, UNIT_GRAD, UNIT_RAD, UNIT_TURN, UNIT_MS, S,
		UNIT_KHZ, UNIT_HZ, UNIT_UNKNOWN
	};

protected:
	QString mValue;
	static QStringList mUnitsStr;

public:
	StyleAttribute ( const QString& rValue = QString::null ) {
		setValue ( rValue );
	}

	~StyleAttribute () {

	}

	inline QString getValue () const {
		return mValue;
	}

	void setValue ( const QString& rValue );

	bool isResource ();
	bool isColor ();
	bool isNumber ();
	bool isText ();

	inline bool isNull () {
		return mValue.isNull() || mValue.isEmpty();
	}

	AttributeUnits getUnit ();

	inline StyleAttribute& operator = ( const StyleAttribute& rOther ) {
		mValue = rOther.mValue;
		return *this;
	}

	inline bool operator != ( const StyleAttribute& rOther ) const {
		return mValue != rOther.mValue;
	}

	bool operator == ( const StyleAttribute& rOther ) const {
		return mValue == rOther.mValue;
	}

	static float getFloat ( StyleAttribute& rOther );
	static int getInt ( StyleAttribute& rOther );

	static QColor getColor ( StyleAttribute& rOther );
	static QStringList getResource ( StyleAttribute& rOther );

	static StyleAttribute null;
};

#endif /* STYLEATTRIBUTE_H_ */
